home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snpd1292.zip / ISRAMDSK.C < prev    next >
C/C++ Source or Header  |  1992-12-26  |  1KB  |  54 lines

  1. /*
  2. **  isRamDsk() - Determine if a drive is a RAM disk
  3. **
  4. **  Call with drive letter ('a' - 'z', 'A' - 'Z')
  5. **
  6. **  Returns TRUE, FALSE, or ERROR
  7. **
  8. **  Uses ABSDISKC.C, ABSDISK.ASM, and DOS5BOOT.H from SNIPPETS
  9. **  (Note: The relevent parts of the structure in DOS5BOOT.H are
  10. **   also applicable to lower version numbers of DOS)
  11. **
  12. **  Public domain by Bob Stout
  13. */
  14.  
  15. #include <ctype.h>
  16. #include <dos.h>
  17. #include "dos5boot.h"
  18.  
  19. typedef enum {ERROR = -1, FALSE, TRUE} LOGICAL;
  20.  
  21. LOGICAL isRamDsk(unsigned char drive) 
  22. {
  23.       union REGS regs;
  24.       B_REC buffer;
  25.  
  26.       regs.x.ax = 0x4408;           /* Not if removable     */
  27.       regs.h.bl = toupper(drive) - '@';
  28.       intdos(®s, ®s);
  29.       if (0 == regs.x.ax)
  30.             return FALSE;
  31.       if (AbsDiskRead(toupper(drive) - 'A', 1, 0, &buffer))
  32.             return ERROR;
  33.       return (1 == buffer.bsFATs);
  34.  
  35. #ifdef TEST
  36.  
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39.  
  40. int main(int argc, char *argv[])
  41. {
  42.       if (2 > argc)
  43.       {
  44.             puts("Syntax: ISRAMDSK drive_letter");
  45.             return EXIT_FAILURE;
  46.       }
  47.       printf("Drive %c: is%s a RAM drive\n", toupper(*argv[1]),
  48.             isRamDsk(*argv[1]) ? "" : " not");
  49.       return EXIT_SUCCESS;
  50. }
  51.  
  52. #endif /* TEST */
  53.